<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
</head>

<body>
    <div style="width:750px;height:750px;transform:rotate(90deg);-ms-transform:rotate(90deg);-moz-transform:rotate(90deg);-webkit-transform:rotate(90deg); -o-transform:rotate(90deg);">
        <div style="height:150px;"></div>
        <div id="date" style="font-size:80px;text-align:center;"></div>
        <div id="time" style="font-size:300px;text-align: center;"></div>
        <div id="fix" style="font-size:20px;text-align: center;"></div>
    </div>

    <script>
        var timeFix=0;//浏览器时间与服务器时间的差值,单位分钟,参见函数fixTime

        //由于kindle浏览器时间与本地时间不同步,借助服务器时间修正这个漂移
        function fixTime() {
            var xmlHttp = new XMLHttpRequest();
            if (!xmlHttp) {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            } else {
                xmlHttp = new window.XMLHttpRequest();
            }
            xmlHttp.open("GET", location.href, false);
            xmlHttp.send();
            var severtime = new Date(xmlHttp.getResponseHeader("Date"));
            var localtime = new Date();
            timeFix  = (severtime - localtime)/(60*1000);
		}

		//获取地址栏query参数
        function getParam(item){
			var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)","i"));
			return svalue ? svalue[1] : svalue;
		}

        //数字格式化2位
        function str2(n) {
            return n < 10 ? "0" + n : n;
        }

        //设置指定id对象的文字
        function setText(name, str) {
            var element = document.getElementById(name);
            if (element && element.innerText != str) {
                element.innerText = str;
            }
        }

        //刷新界面时间显示,使用timeFix和query的offset共同修正时间
        function refreshTime() {
            var t = new Date();
            //var utc8DiffMinutes = t.getTimezoneOffset() + 480;
            var minutes=timeFix;
			var param=getParam("offset");
			if(param)
				minutes+=parseInt(param);
            t.setMinutes(t.getMinutes() + minutes);	

            setText("date", t.getFullYear() + "-" + str2(t.getMonth() + 1) + "-" + str2(t
                .getDate()) + " 星期" + "日一二三四五六" [t.getDay()]);

            setText("time", str2(t.getHours()) + ":" + str2(t.getMinutes()));

            setText("fix",timeFix);
        }

        //开始定时刷新时间
        function startTimer() {
            refreshTime();

            setInterval("refreshTime()", 60 * 1000); //每分钟更新检查,此时秒数应为1
        }
		
        function syncTimer() {
			fixTime();//setTimeout("fixTime()", 3600,000);
            refreshTime();

            var t = new Date();
            var s = 61 - t.getSeconds(); //预定下次秒数为1时开始
            setTimeout("startTimer()", s * 1000);

            setTimeout("fixTime()", 30 * 60 * 1000);//30分钟修正一次
        }

        syncTimer();
    </script>
</body>

</html>